home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 949 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  61 lines

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: windows dll
  5. Date: 10 Jan 1996 13:18:56 GMT
  6. Organization: Internet Access Group, Orlando, Florida
  7. Message-ID: <4d0ec0$7aq@news.iag.net>
  8. References: <4csoom$q7t@felix.teclink.net>
  9. NNTP-Posting-Host: pm1-orl23.iag.net
  10. X-Newsreader: WinVN 0.99.7
  11.  
  12. In article <4csoom$q7t@felix.teclink.net>, tmartin@teclink.net says...
  13. >
  14. >I am trying to compile someones source code for a DLL written 
  15. >in MS C7.0. I am using VC 1.0. I keep getting errors saying 
  16. >(warning C4135: conversion between different integral types).
  17. >
  18. >An example of the lines that give the error is listed below:
  19. >
  20. >*(ptr) = pCard->byCompression|pCard->wPlayMode;
  21. <snip>
  22.  
  23. What are the types of ptr, pCard->byCompression, and pCard->wPlayMode?
  24.  
  25. Typically, you might get this type of warning, if ptr is a pointer to
  26. a type that may not be able to store all possible results of the 
  27. expression (eg, if ptr is pointer to char and either pCard->byCompression 
  28. or pCard->wPlayMode is int).  If this is the case and you are _certain_
  29. that your code protects against any out of range results, you can simply
  30. cast the result to silence the warning.  
  31.  
  32. #define TRUE 1
  33. #define FALSE 0
  34.  
  35. struct my_struct
  36.    {
  37.    int byCompression;
  38.    int wPlayMode;
  39.    };
  40.  
  41. int main()
  42.    {
  43.    char c, *ptr = &c;
  44.    struct my_struct ms, *pCard = &ms;                                      
  45.    
  46.    pCard->byCompression = TRUE;
  47.    pCard->wPlayMode = FALSE;
  48.  
  49.    *(ptr) = pCard->byCompression|pCard->wPlayMode;         /* warning */
  50.    *(ptr) = (char)(pCard->byCompression|pCard->wPlayMode); /* no warning */
  51.    
  52.    return (0);
  53.    }
  54.  
  55. <Compiled on MSVC 1.5 with warning level set at 4.>
  56.  
  57. -- 
  58. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  59. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  60.  
  61.